import Vue from 'vue'
    import Vuex from 'vuex'
    Vue.use(Vuex)
	export default new Vuex.Store({
		state:{
            poi:'hello Vuex',
            list:[
{"id": "001","car_num":0,"title": "白菜炒菜花","src":"https://static.shipuxiu.com/t/60/59635_393574.jpg"
}, {"id": "002","car_num":0,"title": "韭菜炒菜花","src":"https://static.shipuxiu.com/t/11/10821_127974.jpg"
}, {"id": "003","car_num":0,"title": "白菜泡菜","src":"https://static.shipuxiu.com/t/20/19212_924522.jpg"
}, {"id": "004","car_num":0,"title": "菜包菜","src":"https://static.shipuxiu.com/t/58/57749_339641.jpg"
}, {"id": "005","car_num":0,"title": "海带白菜烩菜","src":"https://static.shipuxiu.com/t/58/57996_990893.jpg"
}, {"id": "006","car_num":0,"title": "酸溜白菜","src":"https://static.shipuxiu.com/t/0/27_323249.jpg"
}, {"id": "007","car_num":0,"title": "白灼菜心","src":"https://static.shipuxiu.com/t/0/43_893144.jpg"
}, {"id": "008","car_num":0,"title": "香菇手撕包菜","src":"https://static.shipuxiu.com/t/1/93_737249.jpg"
}, {"id": "009","car_num":0,"title": "粉丝娃娃菜","src":"https://static.shipuxiu.com/t/1/96_316903.jpg"
}, {"id": "010","car_num":0,"title": "香菇油菜","src":"https://static.shipuxiu.com/t/1/68_723970.jpg"
}
            ],
			shopingList:[],
			user:[{"username":"123","password":"123"}],
			car_num_all:0,
			username:null,
        },
		getters:{
		  hello(state){
			return "name:"+state.poi
		  }
		},
		mutations:{
			//es6语法，等同edit:funcion(){...}
			edit(state){
				state.poi = 'hello x'
			},
			edita(state){
			  state.poi="hello a"
			},
			addCar(state){
				state.car_num_all+=1
			},
			moveCar(state){
			state.car_num_all-=1
			},
		},
		actions:{
		  helloa({commit}){
			setTimeout(()=>{
			  commit('edita')
			},2000)
		  }
		},
        
	 })